
import wx
from wx.lib.agw.ribbon import toolbar


class ToolBarFrame(wx.Frame):

    def __init__(self):
        wx.Frame.__init__(self, None, id=-1, title='ToolBarFrame', size=(300, 200))
        panel = wx.Panel(self)
        panel.SetBackgroundColour('White')
        #1.创建状态栏
        statusBar = self.CreateStatusBar()
        #2.创建工具栏
        toolbar = self.CreateToolBar()
        qtool = toolbar.AddTool(wx.ID_ANY, "Cut", wx.Bitmap("ac-camera@3x.png"))
        toolbar.Realize()
        # 3.创建两个菜单
        menuBar = wx.MenuBar()
        menu1 = wx.Menu()
        menuBar.Append(menu1, '&File')
        menu2 = wx.Menu()
        copyItem = wx.MenuItem(menu2, id=wx.NewId(), text='&Copy', helpString='help me!!!')
        menu2.Append(copyItem)
        menu2.AppendCheckItem(wx.NewId(), '&Cut', 'Cut selected Text')
        menu2.AppendSeparator()
        menu2.AppendCheckItem(wx.NewId(), '&Option', 'Options')
        menuBar.Append(menu2, '&Edit')
        self.SetMenuBar(menuBar)
        self.Bind(wx.EVT_TOOL, self.onCut, qtool)   #绑定tool的事件
        self.Bind(wx.EVT_CLOSE, self.onClose)       #绑定关闭事件
        # self.Bind(wx.EVT_MENU, self.onOpneFile, menu1)
        self.Bind(wx.EVT_MENU, self.onCopy, copyItem)

    def onClose(self, event):
        self.Destroy()


    def onCut(self, event):
        """拍照事件"""
        print('Cut!!!')
        dlg = wx.SingleChoiceDialog(None, message='Select your fruit.', caption='选择', choices=['apple', 'brana', 'o'])
        dlg.SetSelection(2) #设置默认选中的item
        if dlg.ShowModal() == wx.ID_OK:
            print(dlg.GetStringSelection())

    def onOpenFile(self, event):
        print('open file')

    def onCopy(self, event):
        print('Copy')


if __name__ == '__main__':
    app = wx.App()
    frame = ToolBarFrame()
    frame.Show()
    app.MainLoop()

